package com.prs.crm.domain.oa;

import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.prs.crm.domain.BaseEntity;
import com.prs.crm.domain.hr.Person;

@Entity
@Table(name="oa_synod")
public class Synod extends BaseEntity{
	
	private static final long serialVersionUID = 1L;
	
	@Id@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	@ManyToOne
	private SynodType type;
	private String title;
	private Date beginTime;
	private Date endTime;
	private String attach;
	@Lob
	private String content;
	@Lob
	private String remark;
	//1:会议准备，2：会议记录，3：会议处理，会议结束
	private String state;
	@ManyToMany(fetch=FetchType.LAZY)
	private Set<Person> joinPersons;
	@ManyToOne
	private SynodRoom synodRoom;
	@OneToOne(fetch=FetchType.LAZY,mappedBy="synod")
	private SynodRecord synodRecord;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public SynodType getType() {
		return type;
	}
	public void setType(SynodType type) {
		this.type = type;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}

	public Date getBeginTime() {
		return beginTime;
	}
	public void setBeginTime(Date beginTime) {
		this.beginTime = beginTime;
	}
	public Date getEndTime() {
		return endTime;
	}
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	public String getAttach() {
		return attach;
	}
	public void setAttach(String attach) {
		this.attach = attach;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public void setJoinPersons(Set<Person> joinPersons) {
		this.joinPersons = joinPersons;
	}
	public Set<Person> getJoinPersons() {
		return joinPersons;
	}
	
	public void addJoinPersons(Collection<Person> persons) {
		if(joinPersons == null) {
			joinPersons = new HashSet<Person>();
		}
		else {
			joinPersons.clear();
		}
		if(persons != null) {
			joinPersons.addAll(persons);
		}
	}
	public void setSynodRoom(SynodRoom synodRoom) {
		this.synodRoom = synodRoom;
	}
	public SynodRoom getSynodRoom() {
		return synodRoom;
	}
	public void setSynodRecord(SynodRecord synodRecord) {
		this.synodRecord = synodRecord;
	}
	public SynodRecord getSynodRecord() {
		return synodRecord;
	}

}
